<cfcomponent output="false">
	
	<!--- --->
	
	<cffunction name="saveWorkweekEvents" access="public" output="true" returntype="void">

		<cfset var local = {} />
		
		<cfset local.duration = 0 />
		<cfif isNumeric(arguments.duration_hour)>
			<cfset local.duration = arguments.duration_hour * 60 />
		</cfif>
		<cfset local.duration = local.duration + arguments.duration_minute />

		<cftransaction>
			<cfloop list="#arguments.days#" index="local.i" item="local.day">
				<cfset $.run.it('workweekService.saveWorkweekEvent', {
					name = arguments.name,
					duration = local.duration,
					weekday = local.day,
					category=arguments.category
				}) />
			</cfloop>
		</cftransaction>

		<cflocation url="#$.site.getVar('rootURL')#/craftivity/workweek.cfm" addToken="no" />

	</cffunction>

	<!--- --->
	
	<cffunction name="deleteWorkweekEvent" access="public" output="true" returntype="void">
		<cfargument name="id" required="true" />

		<cfset var local = {} />
		
		<cfset $.database.delete(
			id=arguments.id,
			table="workweek_event"
		) />
		
		<cflocation url="#$.site.getVar('rootURL')#/craftivity/workweek.cfm" addToken="no" />

	</cffunction>

	<!--- --->

</cfcomponent>